﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace OneRed.Main.Comm
{
    public class Bind2Combox
    {
        public static void BindSortList2Combox(ComboBox cbContner, SortedList<string, string> value, string Order = "Asc")
        {
            cbContner.Items.Clear();
            if (Order == "Asc")
            {
                foreach (KeyValuePair<string, string> key in value)
                {
                    cbContner.Items.Add(new ComboBoxItem().Content = key.Key);
                }
            }
            else
            {
                foreach (KeyValuePair<string, string> key in Enumerable.Reverse(value))
                {
                    cbContner.Items.Add(new ComboBoxItem().Content = key.Key);
                }
            }
            cbContner.SelectedIndex = 0;
        }
    }
}
